package controller;

import model.*;
import view.UI;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class Controller {
    private DataSource dataSource;
    private UI ui;
    public FatherPlayer nowPlayer;
    private ArrayList<Card> allList;
    private PersonPlayer personPlayer;


    private WestPcPlayer westPcPlayer;
    private EastPcPlayer eastPcPlayer;
    public UnderPlayer underPlayer;
    public ArrayList<Card> deskList;
    public boolean judge = true;
    public MouseLis mouseLis;


    public Controller() {
        ui = new UI(this);
        mouseLis = new MouseLis(this);
        dataSource = new DataSource();
        allList = new ArrayList<>();
        personPlayer = new PersonPlayer();
        westPcPlayer = new WestPcPlayer();
        eastPcPlayer = new EastPcPlayer();
        underPlayer = new UnderPlayer();
        deskList = new ArrayList<>();


        // 随机当前玩家
        nowPlayer = personPlayer;
        personPlayer.nextPlayer = westPcPlayer;
        westPcPlayer.nextPlayer = eastPcPlayer;
        eastPcPlayer.nextPlayer = personPlayer;

        initCard();

    }

    public void initCard() {
        String[] str = {"黑桃", "红桃", "梅花", "方块"};
        for (String s : str) {
            for (int i = 1; i <= 13; i++) {
                Card card = new Card(s, i, true, false, 100, this);
                allList.add(card);
            }
        }
        Card card2 = new Card("小王", 51, true, false, 100, this);
        allList.add(card2);
        Card card3 = new Card("大王", 52, true, false, 100, this);
        allList.add(card3);
        Collections.shuffle(allList);

    }






    public DataSource getDataSource() {
        return dataSource;
    }

    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    public UI getUi() {
        return ui;
    }

    public void setUi(UI ui) {
        this.ui = ui;
    }

    public FatherPlayer getNowPlayer() {
        return nowPlayer;
    }

    public void setNowPlayer(FatherPlayer nowPlayer) {
        this.nowPlayer = nowPlayer;
    }

    public ArrayList<Card> getAllList() {
        return allList;
    }

    public void setAllList(ArrayList<Card> allList) {
        this.allList = allList;
    }

    public PersonPlayer getPersonPlayer() {
        return personPlayer;
    }

    public void setPersonPlayer(PersonPlayer personPlayer) {
        this.personPlayer = personPlayer;
    }

    public ArrayList<Card> getDeskList() {
        return deskList;
    }

    public void setDeskList(ArrayList<Card> deskList) {
        this.deskList = deskList;
    }

    public WestPcPlayer getWestPcPlayer() {
        return westPcPlayer;
    }

    public void setWestPcPlayer(WestPcPlayer westPcPlayer) {
        this.westPcPlayer = westPcPlayer;
    }

    public EastPcPlayer getEastPcPlayer() {
        return eastPcPlayer;
    }

    public void setEastPcPlayer(EastPcPlayer eastPcPlayer) {
        this.eastPcPlayer = eastPcPlayer;
    }



}
